home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d18 / nrpas13.arc / SORT2.DEM < prev    next >
Text File  |  1991-05-01  |  1KB  |  61 lines

  1. PROGRAM d8r4(input,output,dfile);
  2. (* driver for routine SORT2 *)
  3. CONST
  4.    np=100;
  5. TYPE
  6.    glsarray=ARRAY [1..np] OF real;
  7. VAR
  8.    i,j : integer;
  9.    a,b : glsarray;
  10.    dfile : text;
  11.  
  12. (*$I MODFILE.PAS *)
  13. (*$I SORT2.PAS *)
  14.  
  15. BEGIN
  16.    glopen(dfile,'tarray.dat');
  17.    readln(dfile);
  18.    FOR i := 1 to 100 DO BEGIN
  19.       read(dfile,a[i])
  20.    END;
  21.    close(dfile);
  22. (* generate b-array *)
  23.    FOR i := 1 to 100 DO BEGIN
  24.       b[i] := i-1
  25.    END;
  26. (* sort a and mix b *)
  27.    sort2(100,a,b);
  28.    writeln('after sorting a and mixing b, array a is:');
  29.    FOR i := 1 to 10 DO BEGIN
  30.       FOR j := 1 to 10 DO BEGIN
  31.          write(a[10*(i-1)+j]:6:2)
  32.       END;
  33.       writeln
  34.    END;
  35.    writeln('... and array b is:');
  36.    FOR i := 1 to 10 DO BEGIN
  37.       FOR j := 1 to 10 DO BEGIN
  38.          write(b[10*(i-1)+j]:6:2)
  39.       END;
  40.       writeln
  41.    END;
  42.    writeln('press return to continue...');
  43.    readln;
  44. (* sort b and mix a *)
  45.    sort2(100,b,a);
  46.    writeln('after sorting b and mixing a, array a is:');
  47.    FOR i := 1 to 10 DO BEGIN
  48.       FOR j := 1 to 10 DO BEGIN
  49.          write(a[10*(i-1)+j]:6:2)
  50.       END;
  51.       writeln
  52.    END;
  53.    writeln ('... and array b is:');
  54.    FOR i := 1 to 10 DO BEGIN
  55.       FOR j := 1 to 10 DO BEGIN
  56.          write(b[10*(i-1)+j]:6:2)
  57.       END;
  58.       writeln
  59.    END
  60. END.
  61.